define("m_basepage", ["m_zepto", "m_toast"], function(t, n) {
    function a(t) {
        var e = new RegExp("(^|&)" + t + "=([^&]*)(&|$)", "i"), i = window.location.search.substr(1).match(e);
        return i ? decodeURIComponent(i[2]) : null
    }
    var o = function() {//定义了 m_basepage构造函数
        this.page = {},
        this.jdom = null,
        this.renderComplete = !1,
        this.startStayTime = null,
        this.startRenderTime = null,
        this.initialize.apply(this, arguments);//新建page对象后自动初始化
        this.bind_PM_Events();
            //e.register(this)
    };
    t.extend(o.prototype, {//利用zepto 扩展 m_basepage 的原型 
        initialize: function() {},
        init: function() {//初始化
                this.page.wrapper = t('.virtualPage[page="' + this.page.name + '"]'),//容器
                this.inThisPage = !1,
                this.lastLeaveSH = 0,
                this.bindMethod()
        },
        pageAdd: function() {
            var e = this.page;
            if(0 === t(".virtualPage[page=" + e.name + "]").length){
                t("#wrapper").append(e.html); 
                this.jdom = t(".virtualPage[page=" + e.name + "]"),
                t(".virtualPage[page=" + e.name + "]").css({"height":'100%','display':'block'})
            }
            else if((e.html).length>0){
                t(".virtualPage[page=" + e.name + "]").replaceWith(e.html); 
                this.jdom = t(".virtualPage[page=" + e.name + "]"),
                t(".virtualPage[page=" + e.name + "]").css({"height":'100%','display':'block'})
            }
               
        },
        enter: function() {},
        leave: function() {},
        back: function() {},
        _renderHtml: function() {},
        bindMethod: function() {},
        bind_PM_Events: function() {
            var e = this;
            t.bind(this, "vpageLeave", function(t) {
                e.inThisPage = !1,
                e.renderComplete = !1,
                e.sendStatistic("stayTime", new Date - e.startStayTime),
                e.lastLeaveSH = window.scrollY, e.leave(t)
            }),
            t.bind(this, "vpageEnter", function(t) {
                e.inThisPage = !0,
                    e.startStayTime = new Date,
                    e.startRenderTime = new Date,
                    e.sendStatistic("pv", 1),
                    window.scrollTo(0, 0), e.enter(t)
            }),
            t.bind(this, "vpageBack", function(t) {
                e.inThisPage = !0,
                    e.startStayTime = new Date,
                    e.sendStatistic("pv", 1),
                    window.scrollTo(0, e.lastLeaveSH), e.back(t)
            }),
            t.bind(this, "vpageInit", this.init),
            t.bind(this, "vpageAdd", this.pageAdd)
        },
        request: function(t) {
            var e = this, o = function() {},
                r = t.success ? t.success : o, s = t.error ? t.error : o, c = [];
            t.params.action && (c = t.params.action.split(","));
            var l = t.params.log && "0" == t.params.log;
            !window.needGFIFStat || window.doneGFIFStat || l || (t.params.i_f = a("i_f") || "", t.params.g_f = a("g_f") || "", window.doneGFIFStat = !0), t.type = t.type || "GET", t.dataType = t.dataType || "json";//t.params.sid = i.getSid();
            var d = function(t) {
                for (var i = 0, a = c.length; a > i; i++) {
                    var o = t[c[i]];
                    if (o && o.code && o.code < 0) {
                        o.msg && n.showTip(o.msg, !0, "error");
                        break
                    }
                }
                t.code < 0 ? (t.msg && n.showTip(t.msg, !0, "error"), s.call(e, t)) : r.call(e, t), e.renderComplete || (e.renderComplete = !0, e.sendStatistic("renderTime", new Date - e.startRenderTime))
            };
            t.success = function(t) {
                d.call(e, t)
            },
            t.error = function() {
                n.showTip("网络异常，请刷新重试", !0, "error"), s.apply(e, arguments)
            },
            this._ajax(t)
        },
        _ajax: function(e) {
            t.ajax(
                {
                    dataType: e.dataType,
                    type: e.type,
                    url: e.url,
                    data: e.params,
                    beforeSend: function() {
                        e.noTips || t.trigger(window, "ajaxBeforeSend")
                    },
                    xhrFields: {withCredentials: !0},
                    success: e.success,
                    error: e.error,
                    timeout: 6e3,
                    complete: function() {
                        e.noTips || t.trigger(window, "ajaxComplete")
                    }})
        },
        sendStatistic: function() {}
    }),
    o.extend = function(e, i) {
        var n, a = o, r = function() {};
        return n = e && e.hasOwnProperty("constructor") ? e.constructor : function() {
            a.apply(this, arguments)
        },
        t.extend(n, a),
        r.prototype = a.prototype,
        n.prototype = new r,e && t.extend(n.prototype, e), i && t.extend(n, i),
        n.prototype.constructor = n,
        n.__super__ = a.prototype, n
    },
    o.getQueryString = a;
    var r = function(t, e) {
        var i, n, a, o = t.split("&"), r = {};
        for (a = o.length, i = 0; a > i; i++)
            o[i].indexOf("=") < 0 ? r[o[i]] = void 0 : (n = o[i].split("="), r[n[0]] = e ? decodeURIComponent(n[1]) : n[1]);
        return r
    };
    return o.getURLQuery = function(t) {//获取？后#前面的参数
        var e = t.split("?")[1].split("#")[0];
        return e ? r(e) : {}
    }, o.getHashParams = function(t) {//获取哈希参数
        var e = t ? t : decodeURIComponent(location.hash), i = [], n = {};
        return e.replace(/[\.\?'"><:;,\[\]\{\}]/gi, ""),
            i = e.split("/"), i.length > 0 && (n.__vpageid = i.splice(0, 1)[0].substring(1), n.urlParams = i.length > 0 ? r(i.join("/"), !0) : {}), n
    },o;
});